<template>

    <div>
        <h1>登录页面</h1>
        用户名：<input type="text" v-model="username">
        密码：<input type="password" v-model="password">
        <button @click="login">登录</button>
    </div>

</template>

<script>
export default {
    data() {
        return {
            username:'',
            password:'',
        }
    },
    methods:{
        login(){
            this.axios.post('http://localhost:8000/login/', this.qs.stringify({'username': this.username,'password': this.password})).then(res=>{
                console.log(res.data)
                if (res.data.code == '200'){
                    this.$toast('登录成功')
                    localStorage.setItem('username', res.data.username)
                    localStorage.setItem('user_level', res.data.user_level)
                }
            })
        }
    }
}
</script>

<style>

</style>